﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms.DataVisualization.Charting;

namespace DAL
{
    public class ChartHelper
    {
        public static void AddSeries(Chart chart,String[] name, SeriesChartType[] chartType)
        {
            for (int i = 0; i < name.Length; i++)
            {
                Series series = new Series(name[i]);
                series.ChartType = chartType[i];
                chart.Series.Add(series);
            }
        }



        public static void SetAsisxInterval(Chart chart,int number)
        {
            chart.ChartAreas[0].AxisX.Interval = number;
        }

        public static void DataBindSourceChart(Chart chart,String tableName,int series,String x,String y)
        {
            chart.DataSource = DBHelper.Select("SELECT * FROM " + tableName);
            chart.Series[series].XValueMember = x;
            chart.Series[series].YValueMembers = y;
        }

        public static void DataBindSourceChartWithSql(Chart chart, String sql, int series, String x, String y)
        {
            chart.DataSource = DBHelper.Select(sql);
            chart.Series[series].XValueMember = x;
            chart.Series[series].YValueMembers = y;
        }

    }
}
